<template>
	<view class="wrap">
		<view class="comment">
			<view class="top">
				<view class="left">
					<view class="heart-photo">
						<image :src="comment.url" mode=""></image>
					</view>
					<view class="user-info">
						<view class="name">{{ comment.name }}</view>
						<view class="date">06-25 13:58</view>
					</view>
				</view>
				<view class="right" :class="{ highlight: comment.isLike }">
					<view class="likenum">
						{{ comment.likeNum }}
					</view>
					
					<u-icon v-if="!comment.isLike" name="thumb-up" class="like" color="#181818" :size="30"
						@click="getLike"></u-icon>
					<u-icon v-if="comment.isLike" name="thumb-up-fill" class="like" color="red" :size="30"
						@click="getLike"></u-icon>
				</view>
			</view>
			<view class="content">{{ comment.contentText }}</view>
		</view>
		<view class="all-reply">
			<view class="all-reply-top">全部回复（{{ comment.allReply }}）</view>
			<view class="item" v-for="(item, index) in commentList" :key="index">
				<view class="comment">
					<view class="top">
						<view class="left">
							<view class="heart-photo">
								<image :src="item.url" mode=""></image>
							</view>
							<view class="user-info">
								<view class="name">{{ item.name }}</view>
								<view class="date">{{ item.date }}</view>
							</view>
						</view>
						<view class="right">
							<image class="image_huifu" @click="change" src="../../static/users/pingnum.png" mode="">
							</image>
							<view class="like" :class="{ highlight: item.isLike }">
								<view class="num">{{ item.likeNum }}</view>
								<u-icon v-if="!item.isLike" name="thumb-up" :size="30" color="#181818"
									@click="getLike(index)">
								</u-icon>
								<u-icon v-if="item.isLike" name="thumb-up-fill" :size="30" color="red"
									@click="getLike(index)">
								</u-icon>
							</view>
						</view>
					</view>
					<view class="reply" v-if="item.reply">
						<view class="username">{{ item.reply.name }}</view>
						<view class="text">{{ item.reply.contentStr }}</view>
					</view>
					<view class="contents">{{ item.contentText }}</view>
				</view>
			</view>
		</view>

		<view class="shuru" v-if="showhuifu">
			<view class="ipt">
				<input cursor-spacing="30" maxlength="-1" auto-blur="true" focus="have" @blur="clear" value=""
					placeholder="" />
			</view>
			<view class="send">
				发送
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				commentList: [],
				comment: '',
				showhuifu: false,
				have: false
			};
		},
		onLoad() {
			this.getReply();
		},
		methods: {
			clear() {
				this.showhuifu = false
			},
			change() {
				this.showhuifu = true
				this.have = true
			},
			// 点赞
			getLike(index) {
				if (index === 0 || index > 0) {
					this.commentList[index].isLike = !this.commentList[index].isLike;
					if (this.commentList[index].isLike == true) {
						this.commentList[index].likeNum++;
					} else {
						this.commentList[index].likeNum--;
					}
				} else {
					if (this.comment.isLike == true) {
						this.comment.isLike = !this.comment.isLike;
						this.comment.likeNum--;
					} else {
						this.comment.isLike = !this.comment.isLike;
						this.comment.likeNum++;
					}
				}
			},

			// 回复列表
			getReply() {
				this.comment = {
					id: 1,
					name: '叶轻眉',
					date: '12-25 18:58',
					contentText: '我不信伊朗会没有后续反应，美国肯定会为今天的事情付出代价的我不信伊朗会没有后续反应',
					url: 'https://cdn.uviewui.com/uview/template/SmilingDog.jpg',
					allReply: 12,
					likeNum: 33,
					isLikes: false
				};
				this.commentList = [{
						name: '新八几',
						date: '12-25 18:58',
						contentText: '不要乱打广告啊喂！虽然是真的超好用',
						url: 'https://cdn.uviewui.com/uview/template/SmilingDog.jpg',
						likeNum: 33,
						isLike: false,
						reply: {
							name: 'uview',
							contentStr: 'uview是基于uniapp的一个UI框架，代码优美简洁，宇宙超级无敌彩虹旋转好用，用它！'
						}
					},
					{
						name: '叶轻眉1',
						date: '01-25 13:58',
						url: 'https://cdn.uviewui.com/uview/template/SmilingDog.jpg',
						contentText: '我不信伊朗会没有后续反应，美国肯定会为今天的事情付出代价的',
						allReply: 0,
						likeNum: 11,
						isLike: false,
						reply: {
							name: '粘粘',
							contentStr: '今天吃什么，明天吃什么，晚上吃什么，我只是一只小猫咪为什么要烦恼这么多'
						}
					},
					{
						name: '叶轻眉2',
						date: '03-25 13:58',
						contentText: '我不信伊朗会没有后续反应，美国肯定会为今天的事情付出代价的',
						allReply: 0,
						likeNum: 21,
						url: 'https://cdn.uviewui.com/uview/template/SmilingDog.jpg',
						isLike: false,
						allReply: 2,
						reply: {
							name: '豆包',
							contentStr: '想吃冰糖葫芦粘豆包，但没钱5555.........'
						}
					},
					{
						name: '叶轻眉3',
						date: '06-20 13:58',
						contentText: '我不信伊朗会没有后续反应，美国肯定会为今天的事情付出代价的',
						allReply: 0,
						likeNum: 150,
						url: 'https://cdn.uviewui.com/uview/template/SmilingDog.jpg',
						isLike: false
					}
				];
			}
		}
	};
</script>

<style lang="scss" scoped>
	page {
		background-color: #f2f2f2;
	}
    .likenum{
		position: absolute;
		top: 42rpx;
		right: 45rpx;
		font-size: 26rpx;
	}
	.comment {
		padding: 30rpx;
		font-size: 32rpx;
		background-color: #ffffff;

		.top {
			display: flex;
			justify-content: space-between;

		}

		.content {
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #181818;
		}

		.contents {
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #181818;
		}

		.left {
			display: flex;

			.heart-photo {
				image {
					width: 64rpx;
					height: 64rpx;
					border-radius: 50%;
					background-color: #f2f2f2;
				}
			}

			.user-info {
				margin-left: 10rpx;

				.name {

					color: #181818;
					font-size: 28rpx;
					margin-bottom: 4rpx;
				}

				.date {
					font-size: 20rpx;
					color: $u-light-color;
				}
			}
		}

		.right {
			flex: 1;
			padding-left: 20rpx;
			font-size: 30rpx;
			position: relative;

			.top {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-bottom: 10rpx;

				image {
					margin-right: 10rpx;
					width: 26rpx;
					height: 6rpx;
				}

				.name {

					color: #181818;
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #181818;
				}


			}

			.like {
				position: absolute;
				bottom: 0rpx;
				right: 10rpx;
				display: flex;
				align-items: center;
				color: #9a9a9a;
				font-size: 26rpx;

				.num {
					margin-right: 4rpx;
					color: #181818;
				}

			}

			.image_huifu {
				position: absolute;
				right: 120rpx;
				bottom: 2rpx;
				width: 24rpx;
				height: 22rpx;
			}

			.highlight {
				color: #181818;

				.num {
					color: red;
				}
			}

			.content {
				margin-bottom: 10rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #181818;
			}

			.reply-box {
				background-color: rgb(242, 242, 242);
				border-radius: 12rpx;

				.item {
					padding: 20rpx;
					border-bottom: solid 2rpx $u-border-color;

					.username {
						font-size: 24rpx;
						color: #999999;
					}

					.text {
						font-size: 24rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #181818;
					}
				}

				.all-reply {
					padding: 20rpx 0 20rpx 20rpx;
					display: flex;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #181818;
					align-items: center;

					.more {
						margin-left: 6rpx;
					}
				}
			}

			.bottom {
				margin-top: 20rpx;
				display: flex;
				font-size: 24rpx;
				color: #9a9a9a;

				.reply {

					color: #181818;
					margin-left: 10rpx;
				}
			}
		}

		.highlight {
			color: #9a9a9a;

			.num {
				color: #9a9a9a;
			}
		}
	}

	.all-reply {
		margin-top: 10rpx;
		padding-top: 20rpx;
		background-color: #ffffff;

		.all-reply-top {
			margin-left: 20rpx;
			padding-left: 20rpx;
			border-left: solid 4rpx #5677fc;
			font-size: 30rpx;
			font-weight: bold;
		}

		.item {
			border-bottom: solid 2rpx $u-border-color;
		}

		.reply {
			padding: 20rpx;
			background-color: rgb(242, 242, 242);
			border-radius: 12rpx;
			margin: 10rpx 0;

			.username {
				font-size: 24rpx;
				color: #7a7a7a;
			}

			.text {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #181818;
			}
		}
	}

	.shuru {
		// padding-bottom:20rpx;
		position: fixed;
		bottom: 0rpx;
		width: 750rpx;
		height: 120rpx;
		background: #F2F4FA;

		.ipt {
			margin: 20rpx 0 30rpx 30rpx;
			width: 570rpx;
			// height: 100rpx;
			background: #FFFFFF;
			border-radius: 50rpx;
			position: absolute;

			input {
				width: 540rpx;
				height: 80rpx;
				margin: 10rpx 0 0 20rpx;
			}
		}

		.image_one {
			position: absolute;
			right: 64rpx;
			top: 36rpx;
			width: 36rpx;
			height: 36rpx;
		}

		.image_two {
			position: absolute;
			right: 64rpx;
			top: 102rpx;
			width: 36rpx;
			height: 36rpx;
		}

		.send {
			position: absolute;
			top: 35rpx;
			right: 30rpx;
			width: 100rpx;
			height: 50rpx;
			background: #181818;
			border-radius: 10rpx;
			text-align: center;
			line-height: 50rpx;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
</style>
